package model; /**
 * <Description>
 *
 * @author CJJ
 * @version 1.0
 * @createDate 2020/06/29 9:04
 */
 
import lombok.Data;
import lombok.NoArgsConstructor;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
/**
 * <Description>
 *
 * @author CJJ
 * @version 1.0
 * @createDate 2019/08/30 17:22
 */
@NoArgsConstructor
@Data
public class TreeVo<T extends TreeVo> implements Comparable<TreeVo> {
 
    protected String id;
    protected String parentId;
    private String name;
    /**
     * 排序 每一层单独排序
     */
    protected Integer sort;
 
    protected ArrayList<T> children = new ArrayList<>(
 
    );
 
    public TreeVo(String treeRootId) {
        this.id = treeRootId;
    }
 
    public TreeVo(String id, String parentId, String name) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;
    }
 
    public void setChildren(ArrayList<T> children) {
        Collections.sort(children);
        this.children = children;
    }
 
 
    @Override
    public int compareTo(TreeVo o) {
        return sort.compareTo(o.getSort());
    }
}